package org.third.common.utils;

import java.security.GeneralSecurityException;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;

import org.postgresql.ssl.WrappedFactory;

/**
 * Created by Huailong Tang(Jason) on 2018/1/2.
 */
public class SingleCertValidatingFactory extends WrappedFactory{

  public SingleCertValidatingFactory(String sslFactoryArgs) throws GeneralSecurityException {
    SSLContext ctx = SSLContext.getInstance("TLS");
    ctx.init(null,new TrustManager[]{new SingleCertTrustManager(sslFactoryArgs)},null);
    _factory = ctx.getSocketFactory();
  }
}
